/**
 * 安卓白金英雄坛制作组 <br>
 * 文件名：ProgressScreen.java <br>
 * 创建时间：2013-8-30 上午11:45:23 <br>
 * 所属项目：GmudEX <br>
 * @author 12548 <br>
 */
package lostland.gmud.exv2.ui.core;

import lostland.gmud.exv2.Gmud;
import lostland.gmud.exv2.blgframework.impl.BLGGraphics;

/**
 * 类名：DoubiScreen <br>
 * 说明：ProgressScreen的变种，读一个逗比的进度条
 *
 * @author 12548
 */
public abstract class DoubiScreen extends SlowScreen {

	int speed;
	protected int max;
	protected int now = 0;

	public DoubiScreen(float ticktime, int speed, int max) {
		super(ticktime);
		this.speed = speed;
		this.max = max;
	}

	@Override
	public void tick() {
		now += speed;
		if (now >= max) {
			getGame().popScreen();
			onComplete();
		}
	}

	public abstract void onComplete();

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.ui.core.FixedScreen#draw()
	 */
	@Override
	public void present(float t) {
		BLGGraphics g = (BLGGraphics) getGame().getGraphics();
		if (max <= 0) return;
		g.drawRect(0, 2, 320, 16, Gmud.getBgColor());
		g.drawRectOutline(30, 2, 200, 16, 0);
		final int x = 30, y = 2, height = 16;
		final int width = Math.min((int) (now * 1.0 / max * 200 + 30), 200);
		g.drawRect(x, y, width, height, 0);

	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.ui.core.SlowScreen#onClick(int, int)
	 */
	@Override
	protected void onClick(int tx, int ty) {
	}


}
